#include <stdio.h>
#include <flgrCoreData.h>
#include <flgrCoreDataIO.h>
#include <flgrCoreCopy.h>
#include <flgrCoreGeometry.h>
#include "../macro.h"

/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr_rec_open types
/////////////////////////////////////////////////////////////////////////
#define tstSet_Data1d_Vector(dtype)				\
								\
  fgUINT8 rawref[]={0, 0, 0, 0, 0, 0, 0, 0, 0, 1};		\
								\
  FLGR_Vector *vec;						\
  FLGR_Data1D *dat, *datref, *datrefcp;				\
  FLGR_Ret ret;							\
  dtype val=1;							\
								\
  datref    = flgr1d_create_##dtype(10,1,FLGR_NO_SHAPE);	\
  dat       = flgr1d_create_##dtype(10,1,FLGR_NO_SHAPE);	\
  datrefcp  = flgr1d_create_fgUINT8(10,1,FLGR_NO_SHAPE);	\
								\
  vec = flgr_vector_create(dat->spp,dat->type);			\
  flgr_vector_populate_from_scalar(vec,&val);			\
								\
  flgr1d_import_raw_ptr(datrefcp,rawref);			\
  flgr1d_copy(datref,datrefcp);					\
  flgr1d_clear_all(dat);					\
								\
  ret = flgr1d_set_data_vector(dat,9,vec);			\
  check_and_display_data1d(datref,dat,ret);			\
								\
								\
  flgr1d_destroy(datref);					\
  flgr1d_destroy(datrefcp);					\
  flgr1d_destroy(dat);						\
  flgr_vector_destroy(vec);					\
								\
  return 1

int testset_data1d_vector_fgBIT(void) {
  tstSet_Data1d_Vector(fgBIT);
}
int testset_data1d_vector_fgUINT8(void) {
  tstSet_Data1d_Vector(fgUINT8);
}
int testset_data1d_vector_fgUINT16(void) {
  tstSet_Data1d_Vector(fgUINT16);
}
int testset_data1d_vector_fgUINT32(void) {
  tstSet_Data1d_Vector(fgUINT32);
}
int testset_data1d_vector_fgINT8(void) {
  tstSet_Data1d_Vector(fgINT8);
}
int testset_data1d_vector_fgINT16(void) {
  tstSet_Data1d_Vector(fgINT16);
}
int testset_data1d_vector_fgINT32(void) {
  tstSet_Data1d_Vector(fgINT32);
}
int testset_data1d_vector_fgFLOAT32(void) {
  tstSet_Data1d_Vector(fgFLOAT32);
}
int testset_data1d_vector_fgFLOAT64(void) {
  tstSet_Data1d_Vector(fgFLOAT64);
}


/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr_rec_open types
/////////////////////////////////////////////////////////////////////////
#define tstGet_Data1d_Vector(dtype)				\
								\
  fgUINT8 rawref[]={1, 1, 1, 1, 1, 1, 1, 1, 0, 1};		\
								\
  FLGR_Vector *vec;						\
  FLGR_Data1D *dat,*datref,*datrefcp;				\
  FLGR_Ret ret;							\
								\
  datref   = flgr1d_create_##dtype(10,1,FLGR_NO_SHAPE);		\
  datrefcp = flgr1d_create_fgUINT8(10,1,FLGR_NO_SHAPE);		\
  dat      = flgr1d_create_##dtype(10,1,FLGR_NO_SHAPE);		\
								\
  vec = flgr_vector_create(dat->spp,dat->type);			\
								\
  flgr1d_import_raw_ptr(datrefcp,rawref);			\
  flgr1d_draw_line_str(dat,0,10,"1");				\
								\
  flgr1d_copy(datref,datrefcp);					\
								\
  ret = flgr1d_get_data_vector(datref,8,vec);			\
  flgr1d_set_data_vector(dat,8,vec);				\
								\
  check_and_display_data1d(datref,dat,ret);			\
								\
								\
  flgr1d_destroy(datref);					\
  flgr1d_destroy(dat);						\
  flgr1d_destroy(datrefcp);					\
  flgr_vector_destroy(vec);					\
								\
  return 1

int testget_data1d_vector_fgBIT(void) {
  tstGet_Data1d_Vector(fgBIT);
}
int testget_data1d_vector_fgUINT8(void) {
  tstGet_Data1d_Vector(fgUINT8);
}
int testget_data1d_vector_fgUINT16(void) {
  tstGet_Data1d_Vector(fgUINT16);
}
int testget_data1d_vector_fgUINT32(void) {
  tstGet_Data1d_Vector(fgUINT32);
}
int testget_data1d_vector_fgINT8(void) {
  tstGet_Data1d_Vector(fgINT8);
}
int testget_data1d_vector_fgINT16(void) {
  tstGet_Data1d_Vector(fgINT16);
}
int testget_data1d_vector_fgINT32(void) {
  tstGet_Data1d_Vector(fgINT32);
}
int testget_data1d_vector_fgFLOAT32(void) {
  tstGet_Data1d_Vector(fgFLOAT32);
}
int testget_data1d_vector_fgFLOAT64(void) {
  tstGet_Data1d_Vector(fgFLOAT64);
}


/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr_rec_open types
/////////////////////////////////////////////////////////////////////////
#define tstClear1d_All(dtype)				\
							\
  dtype raw[]={1, 1, 1, 1, 1, 1, 1, 1, 1, 1};		\
							\
  dtype rawref[]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0};	\
							\
  FLGR_Data1D *dat, *datref;				\
  FLGR_Ret ret;						\
							\
  datref  = flgr1d_create_##dtype(10,1,FLGR_NO_SHAPE);	\
  dat     = flgr1d_create_##dtype(10,1,FLGR_NO_SHAPE);	\
							\
  flgr1d_import_raw_ptr(dat,raw);			\
  flgr1d_import_raw_ptr(datref,rawref);			\
							\
  ret = flgr1d_clear_all(dat);				\
  check_and_display_data1d(datref,dat,ret);		\
							\
  flgr1d_destroy(datref);				\
  flgr1d_destroy(dat);					\
							\
  return 1

int testclear1d_all_fgBIT(void) {
  tstClear1d_All(fgBIT);
}
int testclear1d_all_fgUINT8(void) {
  tstClear1d_All(fgUINT8);
}
int testclear1d_all_fgUINT16(void) {
  tstClear1d_All(fgUINT16);
}
int testclear1d_all_fgUINT32(void) {
  tstClear1d_All(fgUINT32);
}
int testclear1d_all_fgINT8(void) {
  tstClear1d_All(fgINT8);
}
int testclear1d_all_fgINT16(void) {
  tstClear1d_All(fgINT16);
}
int testclear1d_all_fgINT32(void) {
  tstClear1d_All(fgINT32);
}
int testclear1d_all_fgFLOAT32(void) {
  tstClear1d_All(fgFLOAT32);
}
int testclear1d_all_fgFLOAT64(void) {
  tstClear1d_All(fgFLOAT64);
}




/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr_rec_open types
/////////////////////////////////////////////////////////////////////////
#define tstExport1d_Data_Ptr(dtype)			\
							\
  dtype rawref[]={1, 0, 1, 1, 1, 0, 0, 1, 0, 0};	\
							\
  FLGR_Data1D *dat, *datref;				\
  FLGR_Ret ret;						\
  dtype val[10]; 					\
							\
  datref  = flgr1d_create_##dtype(10,1,FLGR_NO_SHAPE);	\
  dat     = flgr1d_create_##dtype(10,1,FLGR_NO_SHAPE);	\
							\
  flgr1d_import_raw_ptr(datref,rawref);			\
							\
  ret = flgr1d_export_raw_ptr(val,datref);		\
  flgr1d_import_raw_ptr(dat,val);			\
  check_and_display_data1d(datref,dat,ret);		\
							\
							\
  flgr1d_destroy(datref);				\
  flgr1d_destroy(dat);					\
							\
  return 1

int testexport1d_data_ptr_fgBIT(void) {
  tstExport1d_Data_Ptr(fgBIT);
}
int testexport1d_data_ptr_fgUINT8(void) {
  tstExport1d_Data_Ptr(fgUINT8);
}
int testexport1d_data_ptr_fgUINT16(void) {
  tstExport1d_Data_Ptr(fgUINT16);
}
int testexport1d_data_ptr_fgUINT32(void) {
  tstExport1d_Data_Ptr(fgUINT32);
}
int testexport1d_data_ptr_fgINT8(void) {
  tstExport1d_Data_Ptr(fgINT8);
}
int testexport1d_data_ptr_fgINT16(void) {
  tstExport1d_Data_Ptr(fgINT16);
}
int testexport1d_data_ptr_fgINT32(void) {
  tstExport1d_Data_Ptr(fgINT32);
}
int testexport1d_data_ptr_fgFLOAT32(void) {
  tstExport1d_Data_Ptr(fgFLOAT32);
}
int testexport1d_data_ptr_fgFLOAT64(void) {
  tstExport1d_Data_Ptr(fgFLOAT64);
}


/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr_rec_open types
/////////////////////////////////////////////////////////////////////////
#define tstImport1d_Data_Ptr(dtype)			\
							\
  dtype rawref[]={0, 0, 0, 0, 1, 1, 0, 0, 0, 1};	\
							\
  FLGR_Data1D *dat, *datref;				\
  FLGR_Ret ret;						\
  dtype val[10];					\
							\
  datref  = flgr1d_create_##dtype(10,1,FLGR_NO_SHAPE);	\
  dat     = flgr1d_create_##dtype(10,1,FLGR_NO_SHAPE);	\
							\
  flgr1d_import_raw_ptr(datref,rawref);			\
							\
  flgr1d_export_raw_ptr(val,datref);			\
  ret = flgr1d_import_raw_ptr(dat,val);			\
  check_and_display_data1d(datref,dat,ret);		\
							\
							\
  flgr1d_destroy(datref);				\
  flgr1d_destroy(dat);					\
							\
  return 1

int testimport1d_data_ptr_fgBIT(void) {
  tstImport1d_Data_Ptr(fgBIT);
}
int testimport1d_data_ptr_fgUINT8(void) {
  tstImport1d_Data_Ptr(fgUINT8);
}
int testimport1d_data_ptr_fgUINT16(void) {
  tstImport1d_Data_Ptr(fgUINT16);
}
int testimport1d_data_ptr_fgUINT32(void) {
  tstImport1d_Data_Ptr(fgUINT32);
}
int testimport1d_data_ptr_fgINT8(void) {
  tstImport1d_Data_Ptr(fgINT8);
}
int testimport1d_data_ptr_fgINT16(void) {
  tstImport1d_Data_Ptr(fgINT16);
}
int testimport1d_data_ptr_fgINT32(void) {
  tstImport1d_Data_Ptr(fgINT32);
}
int testimport1d_data_ptr_fgFLOAT32(void) {
  tstImport1d_Data_Ptr(fgFLOAT32);
}
int testimport1d_data_ptr_fgFLOAT64(void) {
  tstImport1d_Data_Ptr(fgFLOAT64);
}
